package com.epi.one.basic.generic.pair;

import com.epi.one.basic.animal.Cat;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @author dxy
 * @version 1.0
 */
public class CatPair<T extends Cat> {
    private T first;
    private T second;

    public CatPair() {

    }

    public CatPair(T param) {


    }
    public CatPair(T first, T second) {
        System.out.println(first.getClass().getName());
        System.out.println(second.getClass().getName());
        TypeReference<CatPair<T>> ref = new TypeReference<>() {};
        System.out.println(ref.getType());

        this.first = first;
        this.second = second;
    }
    public T getFirst() {
        return first;
    }
    public  void setSecond(T newSecond) {
        this.second = newSecond;
    }
    public static  <U> void printU(U u) {
        System.out.println(u);
    }

    abstract class TypeReference<T> {
        Type getType() {
            ParameterizedType superClass = (ParameterizedType) getClass().getGenericSuperclass();
            return superClass.getActualTypeArguments()[0];
        }
    }


}
